<?php /* SVN: $Id: admin_index.ctp 2856 2010-08-27 05:19:24Z sakthivel_135at10 $ */ ?>
<div class="projectComments index js-response clearfix">
	<ul class="filter-list-block clearfix">
        <li <?php if (!empty($this->request->params['named']['filter_id']) && $this->request->params['named']['filter_id'] == ConstMoreAction::Suspend) { echo 'class="active"';} ?>><span class="lightblue-block" title="<?php echo __l('Admin suspended'); ?>"><?php echo $this->Html->link($this->Html->cInt($suspended,false).'<span>' .__l('Admin suspended'). '</span>', array('controller'=>'project_comments','action'=>'index','project_id'=>$project_id,'filter_id' => ConstMoreAction::Suspend), array('escape' => false));?></span> </li>
        <li <?php if (!empty($this->request->params['named']['filter_id']) && $this->request->params['named']['filter_id'] == ConstMoreAction::Flagged) { echo 'class="active"';} ?>><span class="red-block" title="<?php echo __l('System flagged'); ?>"><?php echo $this->Html->link($this->Html->cInt($system_flagged,false).'<span>' .__l('System flagged'). '</span>', array('controller'=>'project_comments','action'=>'index','project_id'=>$project_id,'filter_id' => ConstMoreAction::Flagged), array('escape' => false));?></span> </li>
		<li <?php if (empty($this->request->params['named']['filter_id']) && empty($this->request->params['named']['project_status_id'])) { echo 'class="active"';} ?>><span class="import-block" title="<?php echo __l('All'); ?>"><?php echo $this->Html->link($this->Html->cInt($total_project_comments,false).'<span>' .__l('All'). '</span>', array('controller'=>'project_comments','action'=>'index','project_id'=>$project_id), array('escape' => false));?></span> </li>
	</ul>
<div class="page-count-block clearfix">
<div class="grid_left">
<?php
if(empty($this->request->params['named']['view_type'])) :
    echo $this->element('paging_counter');
endif;
?>
</div>
<div class="grid_left">
<?php if(empty($this->request->params['named']['view_type'])) : ?>
       <?php echo $this->Form->create('ProjectComment' , array('type' => 'get', 'class' => 'normal search-form clearfix','action' => 'index')); ?>
    	<div class="filter-section clearfix">
    		<div class="grid_left">
    			<?php echo $this->Form->input('q', array('label' => __l('Keyword'))); ?>
    		</div>
    		<div class="grid_left">
    			<?php echo $this->Form->submit(__l('Search'));?>
    		</div>
    	</div>
    	<?php echo $this->Form->end(); ?>
	<?php endif; ?>
</div>
</div>
  <?php echo $this->Form->create('ProjectComment' , array('class' => 'normal clearfix','action' => 'update')); ?>
    <?php echo $this->Form->input('r', array('type' => 'hidden', 'value' => $this->request->url)); ?>


<table class="list">
    <tr>
        <?php if(empty($this->request->params['named']['view_type'])) :?>
        <th class="select"><?php echo __l('Select'); ?></th>
        <?php endif; ?>
        <th class="actions"><?php echo __l('Actions');?></th>
		<?php if(empty($this->request->params['named']['view_type'])) : ?>
		<th class="dl"><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Project'), 'Project.name');?></div></th>
		<?php endif; ?>
        <th><div class="js-pagination"><?php echo $this->Paginator->sort(__l('User'), 'User.username');?></div></th>
        <th class="dl"><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Comment'), 'comment');?></div></th>
        <th><div class="js-pagination"><?php echo $this->Paginator->sort(__l('IP'), 'Ip.ip');?></div></th>
        <th><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Posted On'), 'created');?></div></th>
    </tr>
<?php
if (!empty($projectComments)):

$i = 0;
foreach ($projectComments as $projectComment):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
	$status_class='';
	if($projectComment['ProjectComment']['admin_suspend']):
		$status_class= ' js-checkbox-suspended';
	else:
		$status_class= ' js-checkbox-unsuspended';
	endif;
	if($projectComment['ProjectComment']['is_system_flagged']):
		$status_class.= ' js-checkbox-flagged';
	else:
		$status_class.= ' js-checkbox-unflagged';
	endif;
?>
	<tr<?php echo $class;?>>
    	<?php if(empty($this->request->params['named']['view_type'])) :?>
     	<td class="select"><?php echo $this->Form->input('ProjectComment.'.$projectComment['ProjectComment']['id'].'.id', array('type' => 'checkbox', 'id' => "admin_checkbox_".$projectComment['ProjectComment']['id'], 'label' => false, 'class' =>$status_class.' js-checkbox-list')); ?></td>
        <?php endif; ?>
    	<td class="actions dl">
            <div class="action-block">
                <span class="action-information-block">
                    <span class="action-left-block">&nbsp;&nbsp;</span>
                        <span class="action-center-block">
                            <span class="action-info">
                                <?php echo __l('Action');?>
                             </span>
                        </span>
                    </span>
                    <div class="action-inner-block">
                    <div class="action-inner-left-block">
                        <ul class="action-link clearfix">
                            <li><?php echo $this->Html->link(__l('Delete'), array('action' => 'delete', $projectComment['ProjectComment']['id']), array('class' => 'delete js-delete', 'title' => __l('Delete')));?></li>
                    		<?php if($projectComment['ProjectComment']['is_system_flagged']):?>
                                <li>	<?php echo $this->Html->link(__l('Clear flag'), array('action' => 'admin_update_stats', $projectComment['ProjectComment']['id'], 'flag' => 'deactivate'), array('class' => 'clear-flag js-delete', 'title' => __l('Clear flag')));?>
                                </li>
                            <?php else:?>
                                <li>	<?php echo $this->Html->link(__l('Flag'), array('action' => 'admin_update_stats', $projectComment['ProjectComment']['id'], 'flag' => 'active'), array('class' => 'flag js-delete', 'title' => __l('Flag')));?>
                                </li>
                            <?php endif;?>
                            <?php if($projectComment['ProjectComment']['admin_suspend']):?>
                    			<li><?php echo $this->Html->link(__l('Unsuspend'), array('action' => 'admin_update_stats', $projectComment['ProjectComment']['id'], 'flag' => 'unsuspend'), array('class' => 'unsuspend js-delete', 'title' => __l('Unsuspend')));?>
                    			</li>
                    		<?php else:?>
                    			<li><?php echo $this->Html->link(__l('Suspend'), array('action' => 'admin_update_stats', $projectComment['ProjectComment']['id'], 'flag' => 'suspend'), array('class' => 'suspend js-delete', 'title' => __l('Suspend')));?>
                    			</li>
                    		<?php endif;?>
                   		 </ul>
    					</div>
    					<div class="action-bottom-block"></div>
    				  </div>
              </div>
		</td>
		<?php if(empty($this->request->params['named']['view_type'])) : ?>
		<td class="dl">
              <div class="clearfix">
                 <span title="<?php echo $this->Html->cText($projectComment['Project']['ProjectStatus']['name'],false); ?>" class="project-atatus-info project-status-<?php echo $projectComment['Project']['project_status_id'];?>">
                 <?php echo $this->Html->cText($projectComment['Project']['ProjectStatus']['name']); ?>
                 </span>
		<?php echo $this->Html->link($this->Html->cText($this->Html->truncate($projectComment['Project']['name'],90, array('ending' => '...'))), array('controller'=> 'projects', 'action'=>'view', $projectComment['Project']['slug'], 'admin' => false), array('escape' => false,'title'=>$this->Html->cText($projectComment['Project']['name'],false)));?>	
                </div>
        </td>
		<?php endif;?>
		<td><?php echo $this->Html->link($this->Html->cText($projectComment['User']['username']), array('controller'=> 'users', 'action'=>'view', $projectComment['User']['username'], 'admin' => false), array('escape' => false,'title'=>$this->Html->cText($projectComment['User']['username'],false)));?></td>
				<td class="dl">
			<span class="js-truncate {size:50}">
		      <?php echo $this->Html->cText($projectComment['ProjectComment']['comment']);?>
			</span>
			
        <?php
				if($projectComment['ProjectComment']['admin_suspend']):
					echo '<span class="backeder round-5">'.__l('Admin Suspended').'</span>';
				endif;
				if($projectComment['ProjectComment']['is_system_flagged']):
					echo '<span class="active round-5">'.__l('System Flagged').'</span>';
				endif;
				if(!empty($projectComment['ProjectComment']['project_flag_count'])) :
				     echo '<span class="pub-update round-5">'.__l('User Flagged').'</span>';
				endif;
			?>
	
			</td>
		<td class="dl">
                        <?php if(!empty($projectComment['Ip']['ip'])): ?>
                            <?php echo  $this->Html->link($projectComment['Ip']['ip'], array('controller' => 'users', 'action' => 'whois', $projectComment['Ip']['ip'], 'admin' => false), array('target' => '_blank', 'title' => 'whois '.$projectComment['Ip']['ip'], 'escape' => false)); ?>
							<p>
							<?php
                            if(!empty($projectComment['Ip']['Country'])):
                                ?>
                                <span class="flags flag-<?php echo strtolower($projectComment['Ip']['Country']['iso2']); ?>" title ="<?php echo $projectComment['Ip']['Country']['name']; ?>">
									<?php echo $projectComment['Ip']['Country']['name']; ?>
								</span>
                                <?php
                            endif;
							 if(!empty($projectComment['Ip']['City'])):
                            ?>
                            <span> 	<?php echo $projectComment['Ip']['City']['name']; ?>    </span>
                            <?php endif; ?>
                            </p>
                        <?php else: ?>
							<?php echo __l('N/A'); ?>
						<?php endif; ?>
		</td>
		<td><?php echo $this->Html->cDateTimeHighlight($projectComment['ProjectComment']['created']);?></td>
	</tr>
<?php
    endforeach;
else:
?>
	<tr>
		<td colspan="8" class="notice"><?php echo __l('No Project Comments available');?></td>
	</tr>
<?php
endif;
?>
</table>


<?php
if (!empty($projectComments)):?>
        <?php if(empty($this->request->params['named']['view_type'])) :?>
        <div class="clearfix">
        <div class="grid_left admin-select-block">
            <?php echo __l('Select:'); ?>
            <?php echo $this->Html->link(__l('All'), '#', array('class' => 'js-admin-select-all','title' => __l('All'))); ?>
            <?php echo $this->Html->link(__l('None'), '#', array('class' => 'js-admin-select-none','title' => __l('None'))); ?>
			<?php echo $this->Html->link(__l('Suspended'), '#', array('class' => 'js-admin-select-suspended', 'title' => __l('Suspended'))); ?>
			<?php echo $this->Html->link(__l('Flagged'), '#', array('class' => 'js-admin-select-flagged', 'title' => __l('Flagged'))); ?>
        </div>
        <div class="admin-checkbox-button grid_left">
            <?php echo $this->Form->input('more_action_id', array('class' => 'js-admin-index-autosubmit', 'options'=>$moreActions,'label' => false, 'empty' => __l('-- More actions --'))); ?>
        </div>
        <?php endif; ?>
        <div class="js-pagination grid_right">
            <?php echo $this->element('paging_links'); ?>
        </div>
        </div>
        <div class="hide">
            <?php echo $this->Form->submit('Submit');  ?>
        </div>

        <?php
    endif;
    echo $this->Form->end();
    ?>
</div>
